/*
 * @copyright: Huang Ding
 * @Author: ding-cx
 * @Date: 2022-05-31 10:27:00
 * @LastEditors: ding
 * @LastEditTime: 2022-07-21 16:43:01
 * @Description: 控制记录、陌生人记录等查询、管理
 */

import { actions } from "./actions";
import { hc } from "../hc";
import BaseHttpService from "./BaseHttpService";

export default class RecordService extends BaseHttpService {
  /**
   * 获取控制记录总条数（按时间范围）
   *
   * @param {string} begin 开始时间 形如 yyyy-MM-ddThh:mm:ss
   * @param {string} end 结束时间 形如 yyyy-MM-ddThh:mm:ss
   * @return {*}
   * @memberof BaseHaiQingInterfaceRecordService
   */
  async getSearchControlNum(begin: string, end: string) {
    const operator = actions.SearchControlNum;
    const info: hc.http.IRequestSearchControlNumInfo = {
      DeviceID: this.device.deviceId,
      BeginTime: begin,
      EndTime: end,
    };
    const res = await this.request<hc.http.IResponseSeaerchControlNum>(operator, { info });
    return res;
  }

  /**
   * 获取控制记录人员信息 条件自行传入
   *  - 参考文档 3.22.2
   *
   * @template Response
   * @param {*} searchParams
   * @return {*}
   * @memberof BaseHaiQingInterfaceRecordService
   */
  async getSearchControlPersonInfo<Response>(searchParams: any) {
    const operator = actions.SearchControl;
    const info = searchParams;
    const res = await this.request<Response>(operator, { info });
    return res;
  }

  /**
   * 获取抓拍记录总条数（按时间范围）
   *
   * @param {string} begin 开始时间 形如 yyyy-MM-ddThh:mm:ss
   * @param {string} end 结束时间 形如 yyyy-MM-ddThh:mm:ss
   * @return {*}
   * @memberof BaseHaiQingInterfaceRecordService
   */
  async getSearchCaptureNum(begin: string, end: string) {
    const operator = actions.SearchCaptureNum;
    const info: hc.http.IRequestSearchCaptureNumInfo = {
      DeviceID: this.device.deviceId,
      BeginTime: begin,
      EndTime: end,
    };
    const res = await this.request<hc.http.IResponseSearchCaptureNum>(operator, { info });
    return res;
  }

  /**
   * 获取抓拍记录人员信息 条件自行传入
   *  - 参考文档 3.26.2
   *
   * @template Response
   * @param {*} searchParams
   * @return {*}
   * @memberof BaseHaiQingInterfaceRecordService
   */
  async getSearchCapturePersonInfo<Response>(searchParams: any) {
    const operator = actions.SearchCapture;
    const info = searchParams;
    const res = await this.request<Response>(operator, { info });
    return res;
  }

  /**
   * 手动推送时间范围内的控制记录
   *
   * @param {string} start 开始时间 形如 yyyy-MM-ddThh:mm:ss
   * @param {string} end 结束时间 形如 yyyy-MM-ddThh:mm:ss
   * @return {*}
   * @memberof BaseHaiQingInterfaceRecordService
   */
  async manualPushControlRecord(start: string, end: string) {
    const operator = actions.ManualPushRecords;
    const info: hc.http.IRequestManualPushRecordsInfo = {
      DeviceID: this.device.deviceId,
      TimeS: start,
      TimeE: end,
    };
    const res = await this.request<hc.http.IResponseManualPushRecords>(operator, { info });
    return res;
  }
}
